<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:replace="adminCommon::common-header">

</head>
<body class="sb-nav-fixed">
<nav th:replace="adminCommon::common-navbar"></nav>
<div id="layoutSidenav">
  <div th:replace="adminCommon::common-sidenav"></div>

  <div id="layoutSidenav_content">
    <main>
      <div class="container-fluid px-4">
        <h1 class="mt-4">添加教练</h1>

        <ol class="breadcrumb mb-4">
          <li class="breadcrumb-item"><a th:href="@{/toCoachMain}">主页</a></li>
          <li class="breadcrumb-item"><a th:href="@{/coach/selCoach}">教练管理</a></li>
          <li class="breadcrumb-item active">添加教练</li>
        </ol>

        <div class="card mb-4">
          <form th:action="@{/coach/addCoach}" method="post" name="addForm"
                onsubmit="return beforeSubmit(this)">
            <table class="table table-hover">
              <tr>
                <td text-align="center">教练id：</td>
                <td><input type="text" class="form-control" placeholder="id由系统自动生成" name="coachId"
                           disabled="disabled">
                </td>
              </tr>
              <tr>
                <td text-align="center">姓名：</td>
                <td><input type="text" class="form-control" placeholder="姓名" name="coachName">
                </td>
              </tr>
              <tr>
                <td text-align="center">密码：</td>
                <td><input type="text" class="form-control" placeholder="初始密码123456"
                           name="coachPassword" disabled="disabled">
                </td>
              </tr>
              <tr>
                <td text-align="center">性别：</td>
                <td><input type="text" class="form-control" placeholder="性别" name="coachGender">
                </td>
              </tr>
              <tr>
                <td text-align="center">年龄：</td>
                <td><input type="text" class="form-control" placeholder="年龄" name="coachAge">
                </td>
              </tr>
              <tr>
                <td text-align="center">联系方式：</td>
                <td><input type="text" class="form-control" placeholder="11位手机号" name="coachPhone">
                </td>
              </tr>
              <tr>
                <td text-align="center">薪资：</td>
                <td><input type="text" class="form-control" placeholder="薪资" name="coachSlave">
                </td>
              </tr>
            </table>
            <div style="text-align:center;margin-top:20px;margin-bottom:20px">
              <input type="submit" class="btn btn-outline-success" value="添加">
            </div>
          </form>
        </div>
      </div>
    </main>
    <footer th:replace="adminCommon::common-footer"></footer>
  </div>
</div>

<div th:include="adminCommon::common-scripts"></div>
<script type="text/javascript">
  function beforeSubmit(addForm) {
    let phone = /^[1][3,4,5,7,8,9][0-9]{9}$/;//设置手机号正则表达式
    if (addForm.coachName.value == "") {
      alert("请输入姓名！")
      return false;
    }
    if (addForm.coachGender.value == "") {
      alert("请输入性别！")
      return false;
    }
    if (addForm.coachAge.value == "") {
      alert("请输入年龄！")
      return false;
    }
    if (!phone.test(addForm.coachPhone.value)) {
      alert("手机号码错误！");
      return false;
    }
    if (addForm.coachSlave.value == "") {
      alert("请输入薪资！")
      return false;
    }
    return true;
  }
</script>
</body>
</html>
